
**# Table 1: Effect of Government Subsidies on Revolving-door Recruitment
import delimited  "/Users/zerenli1992/Dropbox/revolving_door_jmp/replication_files/ind_pref_panel_jop.csv",clear

* save all regression results to a designated folder
global reg_rd  "~/Dropbox/revolving_door_jmp/result"

lab var recruitment_1 "Join"
lab var subsidy_dum "Previous Subsidy"

global reg_setting lab dec(3)  noas   nocons 

reghdfe recruitment_1 subsidy_dum, absorb(jurisdiction_id  year stkcd )  vce(cluster jurisdiction_id) 
outreg2 using "$reg_rd/baseline.tex", replace $reg_setting addtext("Jurisdiction Firm Year FE", "Y" ) cttop("Full") 

reghdfe recruitment_1 subsidy_dum, absorb(jurisdiction_id  year stkcd i.stkcd#c.year i.jurisdiction_id#c.year )  vce(cluster jurisdiction_id)
outreg2 using "$reg_rd/baseline.tex", append $reg_setting addtext("Jurisdiction Firm Year FE", "Y", "Firm Specific Trend", "Y", "Jurisdiction Specific Trend", "Y" ) cttop("Full")  


reghdfe recruitment_1 subsidy_dum, absorb(juris_yr firm_yr  )  vce(cluster jurisdiction_id)
outreg2 using "$reg_rd/baseline.tex", append $reg_setting  addtext("Jurisdiction-Year FE", "Y", "Firm-Year FE", "Y" ) cttop("Full")  


reghdfe recruitment_1 subsidy_dum if level == "prov" , absorb(juris_yr firm_yr  )  vce(cluster jurisdiction_id)
outreg2 using "$reg_rd/baseline.tex", append $reg_setting addtext("Jurisdiction-Year FE", "Y", "Firm-Year FE", "Y" ) cttop("Province")  


reghdfe recruitment_1 subsidy_dum if level == "pref" , absorb(juris_yr firm_yr  )  vce(cluster jurisdiction_id)
outreg2 using "$reg_rd/baseline.tex", append  $reg_setting addtext("Jurisdiction-Year FE", "Y", "Firm-Year FE", "Y" )  cttop("Prefecture") 


reghdfe recruitment_1 subsidy_dum if level == "county" , absorb(juris_yr firm_yr  )  vce(cluster jurisdiction_id)
outreg2 using "$reg_rd/baseline.tex", append  $reg_setting addtext("Jurisdiction-Year FE", "Y", "Firm-Year FE", "Y" ) cttop("County")



**# Table 2: Effect of Future Revolving-door Opportunities on Subsidy Allocation

use "program_replication_jop.dta", clear

encode jurisdiction, g(jurisdiction_id)
encode stkcd, g(stkcd_1)
drop stkcd
rename stkcd_1 stkcd

* generate log variables
g asset_l = log(TotalAsset+1)
g liability_l = log(TotalLiab+1)

* label variables
lab var subsidy_l "Subsidy Value (logged)"
lab var pre_hiring "Future Revolver"
lab var pre_hiring1 "Future Revolver in 1 yr"
lab var pre_hiring2 "Future Revolver in 2 yrs"
lab var pre_hiring3 "Future Revolver in 3 yrs"
lab var asset_l "Asset"
labe var liability_l "Liability"
lab var same_place "Same Place"
lab var rd_offic "Existing Revolvers"

global reg_rd  "~/Dropbox/revolving_door_jmp/result"

** specify firm controls
global firm_controls  asset_l liability_l

** regression setting
global reg_setting  lab dec(3)  nocons  drop($firm_controls)  noas 

**# Table 2: Effect of Future Revolving-door Opportunities on Subsidy Allocation

reghdfe subsidy_l pre_hiring $firm_controls, absorb(jurisdiction_id  year stkcd )  vce(cluster jurisdiction_id) 
outreg2 using "$reg_rd/h2_main.tex", replace $reg_setting  ///
addtext("Firm Controls", "Y", "Jurisdiction FE", "Y", "Firm FE", "Y", "Year FE", "Y", ) 


reghdfe subsidy_l pre_hiring same_place  $firm_controls, absorb(jurisdiction_id  year stkcd )  vce(cluster jurisdiction_id) 
outreg2 using "$reg_rd/h2_main.tex", append $reg_setting ///
addtext("Firm Controls", "Y", "Jurisdiction FE", "Y", "Firm FE", "Y", "Year FE", "Y", ) 



reghdfe subsidy_l pre_hiring same_place rd_offic $firm_controls, absorb(jurisdiction_id  year stkcd)  vce(cluster jurisdiction_id) 
outreg2 using "$reg_rd/h2_main.tex", append $reg_setting ///
addtext("Firm Controls", "Y", "Jurisdiction FE", "Y", "Firm FE", "Y", "Year FE", "Y", ) 


reghdfe subsidy_l pre_hiring same_place rd_offic $firm_controls, absorb(jurisdiction_id  year stkcd i.jurisdiction_id#c.year )  vce(cluster jurisdiction_id) 
outreg2 using "$reg_rd/h2_main.tex", append $reg_setting ///
addtext("Firm Controls", "Y", "Jurisdiction FE", "Y", "Firm FE", "Y", "Year FE", "Y", "Jurisdiction Specific Trend", "Y" ) 


reghdfe subsidy_l pre_hiring same_place rd_offic $firm_controls, absorb(i.juris_firm  year)  vce(cluster jurisdiction_id) 
outreg2 using "$reg_rd/h2_main.tex", append $reg_setting addtext("Firm Controls", "Y", "Jurisdiction-Firm FE", "Y", "Year FE", "Y" ) 


reghdfe subsidy_l pre_hiring1 pre_hiring2 pre_hiring3 same_place rd_offic $firm_controls, absorb(juris_firm  year )  vce(cluster jurisdiction_id) 
outreg2 using "$reg_rd/h2_main.tex", append $reg_setting  addtext("Firm Controls", "Y", "Jurisdiction-Firm FE", "Y", "Year FE", "Y" ) 


**# Table 3: Effect of Subsidies on Firm Compensation

** import compensation analysis data
use "~/Dropbox/revolving_door_jmp/replication_files/earning_df_jop.dta", clear

** export result directory

global reg_rd  "~/Dropbox/revolving_door_jmp/result"

** log transformation of DV
g salary_l = log(salary+1) 
g stock_l = log(stock_value+1)

** log transformation of controls

g asset_l = log(TotalAsset+1)
g liability_l = log(TotalLiab+1)

** encode categorical variables for regressions

encode stkcd, g(stkcd_1)
drop stkcd
rename stkcd_1 stkcd

encode sectorid, g(sectorid_1)
drop sectorid
rename sectorid_1 sectorid

** label variables
lab var subsidy_period_dummy "Previous Subsidy"
label var salary_l "Salary"
label var stock_l "Stock"
global ind_controls  age education  female  bord_mbr 
global firm_controls asset_l liability_l


global reg_setting_h3  lab dec(3) noas nocons drop( $ind_controls $firm_controls)

reghdfe salary_l subsidy_period_dummy  , absorb(stkcd entr_yr )  vce(cluster stkcd) 
outreg2 using "$reg_rd/h3_main.tex", replace  $reg_setting_h3 ///
addtext("Firm and Entry Year FE", "Y",) 

reghdfe salary_l subsidy_period_dummy $ind_controls  , absorb(stkcd entr_yr )  vce(cluster stkcd) 
outreg2 using "$reg_rd/h3_main.tex", append $reg_setting_h3 ///
addtext("Firm and Entry Year FE", "Y",  "Individual Controls", "Y" ) 


reghdfe salary_l subsidy_period_dummy   $firm_controls $ind_controls , absorb(stkcd entr_yr )  vce(cluster stkcd) 
outreg2 using "$reg_rd/h3_main.tex", append  $reg_setting_h3  ///
addtext("Firm and Entry Year FE", "Y",  "Individual Controls", "Y", "Firm Controls", "Y" ) 

reghdfe salary_l subsidy_period_dummy  $firm_controls $ind_controls  , absorb(stkcd entr_yr i.stkcd#c.year)  vce(cluster stkcd) 
outreg2 using "$reg_rd/h3_main.tex", append $reg_setting_h3  ///
addtext("Firm and Entry Year FE", "Y",  "Individual Controls", "Y", "Firm Controls", "Y",  "Firm-specific Trend", "Y" ) 

reghdfe stock_l subsidy_period_dummy  , absorb(stkcd entr_yr )  vce(cluster stkcd) 
outreg2 using "$reg_rd/h3_main.tex", append  $reg_setting_h3 ///
addtext("Firm and Entry Year FE", "Y",) 

reghdfe stock_l subsidy_period_dummy $ind_controls  , absorb(stkcd entr_yr )  vce(cluster stkcd) 
outreg2 using "$reg_rd/h3_main.tex", append $reg_setting_h3 ///
addtext("Firm and Entry Year FE", "Y",  "Individual Controls", "Y" ) 


reghdfe stock_l subsidy_period_dummy   $firm_controls $ind_controls , absorb(stkcd entr_yr )  vce(cluster stkcd) 
outreg2 using "$reg_rd/h3_main.tex", append  $reg_setting_h3  ///
addtext("Firm and Entry Year FE", "Y",  "Individual Controls", "Y", "Firm Controls", "Y" ) 

reghdfe stock_l subsidy_period_dummy  $firm_controls $ind_controls  , absorb(stkcd entr_yr i.stkcd#c.year)  vce(cluster stkcd) 
outreg2 using "$reg_rd/h3_main.tex", append $reg_setting_h3  ///
addtext("Firm and Entry Year FE", "Y",  "Individual Controls", "Y", "Firm Controls", "Y",  "Firm-specific Trend", "Y" ) 


**# Table 4: Firm-level Benefit Analysis 
 
use "/Users/zerenli1992/Dropbox/revolving_door_jmp/replication_files/firm_yr_panel.dta", clear

g asset_l = log(TotalAsset+1)
g liability_l = log(TotalLiab+1)
g subsidy_total_l = log(subsidy_total+1)
g subsidy_local_l = log(subsidy_size+1)
g subsidy_favor_l = log(subsidy_favor+1)
g subsidy_size_13_l = log(subsidy_size_13+1)
lab var relative_tfp "Relative TFP"
lab var asset_l "Size"
lab var liability_l "Liability"
lab var subsidy_total_l "Total Subsidy"
lab var subsidy_local_l "Local Subsidy"
lab var subsidy_favor_l "Favorable Subsidy"
lab var subsidy_size_13_l "Previous Subsidy"
lab var rd_n "Existing Revolver"
lab var rd_favor_dummy "Subsidy Provider"
global reg_setting  lab dec(3) noas nocons drop( $firm_controls) 

** specify firm controls
global firm_controls  asset_l liability_l

reghdfe subsidy_total_l rd_favor_dummy , absorb(stkcd year)  vce(cluster stkcd) 
outreg2 using "$reg_rd/firm_benefit.tex", replace $reg_setting  addtext("Firm and Year FE", "Y")

reghdfe subsidy_total_l rd_favor_dummy rd_n  , absorb(stkcd year)  vce(cluster stkcd) 
outreg2 using "$reg_rd/firm_benefit.tex", append $reg_setting  addtext("Firm and Year FE", "Y")

reghdfe subsidy_total_l rd_favor_dummy rd_n  subsidy_size_13_l , absorb(stkcd year)  vce(cluster stkcd) 
outreg2 using "$reg_rd/firm_benefit.tex", append $reg_setting  addtext("Firm and Year FE", "Y")

reghdfe subsidy_total_l rd_favor_dummy rd_n  subsidy_size_13_l $firm_controls, absorb(stkcd year)  vce(cluster stkcd) 
outreg2 using "$reg_rd/firm_benefit.tex", append $reg_setting  addtext("Firm and Year FE", "Y", "Firm Controls", "Y")




